//
//  PSAreaController.m
//  Btpin
//
//  Created by Vic on 2019/3/30.
//  Copyright © 2019 Vic. All rights reserved.
//

#import "PSAreaController.h"
#import "PSSelectCityView.h"

@interface PSAreaController ()
{
    PSSelectCityView *areaVC;
}
@end

@implementation PSAreaController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = RGBA(0, 0, 0, 0.2);
    
    [self initUI];
}

- (void)initUI {
    NSURL *URL = [[NSBundle mainBundle] URLForResource:@"city" withExtension:@"plist"];
    NSArray *cityArray=[NSArray arrayWithContentsOfURL:URL];
    areaVC = [[PSSelectCityView alloc] initCityData:cityArray CityState:CityStateThird];
    [self.view addSubview:areaVC];
    
    UIButton *resetBtn = [UIToolsControl initButtonWithFrame:CGRectMake(0, EndY(areaVC), WIDTH*0.5, 50) imageName:nil target:self action:@selector(resetBtnTap:) title:@"取消" titleColor:THEMECOLOR_OF_TEXT_666666];
    resetBtn.backgroundColor = COLOR_OF_WHITE;
    resetBtn.titleLabel.font = Font(Font_17);
    [resetBtn borderColor:THEMECOLOR_OF_TEXT_cccccc borderWidth:lineH borderType:BorderSideTypeTop];
    [self.view addSubview:resetBtn];
    
    UIButton *okBtn = [UIToolsControl initButtonWithFrame:CGRectMake(WIDTH/2, EndY(areaVC), WIDTH*0.5, 50) imageName:nil target:self action:@selector(okBtnTap:) title:@"确定" titleColor:COLOR_OF_WHITE];
    okBtn.backgroundColor = THEMECOLOR_OF_ORANGE;
    okBtn.titleLabel.font = Font(Font_17);
    [okBtn borderColor:THEMECOLOR_OF_TEXT_cccccc borderWidth:lineH borderType:BorderSideTypeTop];
    [self.view addSubview:okBtn];
}

- (void)resetBtnTap:(UIButton *)button {
    self.backBlcok(@{});
}
- (void)okBtnTap:(UIButton *)button {
    NSDictionary *dic = [areaVC getAllCityInfo];
    self.backBlcok(dic);
}

@end
